import Cache from './common/cache'
import EventBus from './common/eventbus'
import Message from './common/message'
import PrettyBytes from './common/pretty-bytes'

import {CacheKeyObject, KeyValueObject, DictKeyValueObject} from './common/keyValueObject'
import {strToUnicode, unicodeToStr} from './common/unicode-convert'
import {isEmptyObject, concatArrayObject, concatObject, getNewObject} from './common/util'
import {formatDate, GMTToStr} from './common/typeFormat'
import getDictName from './common/dictFilter'

const components = []

const lib = {
  install: function (Vue, opts) {
    opts = opts | {}

    // Vue组件加载
    // ModuleUtil.loadComponentSync(Vue, components)

    components.map((component) => {
      // console.log('component.name=========', component.name)
      Vue.component(component.name, component)
    })
    // filters.map((filter) => {
    //   Vue.filter(filter.name, filter.filters)
    // })
    Vue.filter('getDictName', getDictName)
    // 内置对象使用
    // Vue.prototype.$Axios = Vue.axios

    // JS对象加载
    Vue.prototype.$KalixCatch = Cache
    Vue.prototype.$KalixEventBus = EventBus
    Vue.prototype.$KalixMessage = Message
    // Vue.prototype.$SearchDataMixin = SearchDataMixin
    // Vue.prototype.$GlobalFilter = GlobalFilter
    // Vue.prototype.$GlobalComponent = GlobalComponent
    // Vue.prototype.$KalixModuleUtil = ModuleUtil

    // JS方法加载
    Vue.prototype.$M_CacheKeyObject = CacheKeyObject
    Vue.prototype.$M_KeyValueObject = KeyValueObject
    Vue.prototype.$M_DictKeyValueObject = DictKeyValueObject
    Vue.prototype.$M_StrToUnicode = strToUnicode
    Vue.prototype.$M_KeyValueObject = KeyValueObject
    Vue.prototype.$M_DictKeyValueObject = DictKeyValueObject
    Vue.prototype.$M_UnicodeToStr = unicodeToStr
    Vue.prototype.$M_IsEmptyObject = isEmptyObject
    Vue.prototype.$M_ConcatArrayObject = concatArrayObject
    Vue.prototype.$M_ConcatObject = concatObject
    Vue.prototype.$M_GetNewObject = getNewObject
    Vue.prototype.$M_FormatDate = formatDate
    Vue.prototype.$M_GMTToStr = GMTToStr
    Vue.prototype.$M_KalixPrettyBytes = PrettyBytes

    // Toml配置加载
    // ModuleUtil.moduleAdd(Vue, 'common')

    let moduleInfo = {
      moduleName: 'lib',
      moduleResolveArr: [],
      moduleKeyArr: []
    }

    Vue.prototype.$module = moduleInfo
  }
}
// ModuleUtil.globalUseComponent(common)
if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use(lib)
}
export default lib
